package com.man.control;


import org.apache.struts2.ServletActionContext;

import com.man.daoService.DaoService;
import com.man.entity.User;

public class LoginAction {
	private DaoService daoService=new DaoService();

	public String sign()
	
	{
		User user=new User();
		user.setUserName(getUserName());
		user.setPassword(getPassword());
		boolean rt=daoService.userSign(user);
		if(rt)
		{
			ServletActionContext.getRequest().getSession().setAttribute("user", user);
			return "success";
		}
		else
		{
			ServletActionContext.getRequest().getSession().setAttribute("msg", "登录失败");
			return "return";
		}

	}
	public String exit()
	{
		ServletActionContext.getRequest().getSession().invalidate();
		return "exit";
	}
	public String register()
	{
		User user=new User();
		user.setUserName(getUserName());
		user.setPassword(getPassword());
		user.setName(getName());
		user.setSex(getSex());
		user.setBirth(getBirth());
		user.setNation(getNation());
		user.setEdu(getEdu());
		user.setWork(getWork());
		user.setPhone(getPhone());
		user.setPlace(getPlace());
		user.setEmail(getEmail());
		boolean rt=daoService.userInsert(user);
		if(rt)
			ServletActionContext.getRequest().getSession().setAttribute("msg", "注册成功");	
		else
			ServletActionContext.getRequest().getSession().setAttribute("msg", "注册失败");
		return "return";
		
	}
	private String userName;  //登录名
	private String password;//登录密码
	private String name;//真实姓名
	private String sex;//用户性别
	private String birth;//出生日期
	private String nation;//用户民族
	private String edu;//用户学历
	private String work;//用户职称
	private String phone;//用户电话
	private String place;//用户住址
	private String email;//用户邮箱
	public String getUserName() {
		return userName;
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getSex() {
		return sex;
	}
	public void setSex(String sex) {
		this.sex = sex;
	}
	public String getBirth() {
		return birth;
	}
	public void setBirth(String birth) {
		this.birth = birth;
	}
	public String getNation() {
		return nation;
	}
	public void setNation(String nation) {
		this.nation = nation;
	}
	public String getEdu() {
		return edu;
	}
	public void setEdu(String edu) {
		this.edu = edu;
	}
	public String getWork() {
		return work;
	}
	public void setWork(String work) {
		this.work = work;
	}
	public String getPhone() {
		return phone;
	}
	public void setPhone(String phone) {
		this.phone = phone;
	}
	public String getPlace() {
		return place;
	}
	public void setPlace(String place) {
		this.place = place;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
}
